package com.hframe.typefilter;

import org.apache.log4j.Logger;

public class ByteArrayToString implements  FilterRef<String, Object> {

	static Logger log = Logger.getLogger(ByteArrayToHex.class);

	@Override
	public String filter(Object object) {
		if (object instanceof byte[]) {
			return toString((byte[]) object);
		}
		return null;
	}

	public static String toString(byte[] by) {
		try {
			String ret = "";
			for (int i = 0; i < by.length; i++) {
				ret += by[i] + "，";
			}
			if (ret.length() > 0)
				return ret.substring(0, ret.length() - 1);
		} catch (Exception e) {
		}
		return "";
	}
}